<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../Another/Style/jquery-ui.css"/>
<script type="text/javascript" src="../Another/JQuery/jquery1.9.2.min.js"></script>
<script type="text/javascript" src="../Another/JQuery/jquery_ui.js"></script>
<link rel="stylesheet" type="text/css" href="../Another/Style/bootstrap.css"/>
<link rel="stylesheet" type="text/css" href="../Another/Style/bootstrap-responsive.css"/>
<script type="text/javascript" src="../Another/JQuery/bootstrap-transition.js"></script>
<script type="text/javascript" src="../Another/JQuery/bootstrap-alert.js"></script>
<script type="text/javascript" src="../Another/JQuery/bootstrap-modal.js"></script>
<script type="text/javascript" src="../Another/JQuery/bootstrap-dropdown.js"></script>
<script type="text/javascript" src="../Another/JQuery/bootstrap-scrollspy.js"></script>
<script type="text/javascript" src="../Another/JQuery/bootstrap-tab.js"></script>
<script type="text/javascript" src="../Another/JQuery/bootstrap-tooltip.js"></script>
<script type="text/javascript" src="../Another/JQuery/bootstrap-popover.js"></script>
<script type="text/javascript" src="../Another/JQuery/jquery.validate.js"></script>
<style>
.control-label{
	margin-left: 100px;
	margin-right: 10px;
}
</style>
<script type="text/javascript">
	  $(document).ready(function(){
			$('input').hover(function()
			{
			$(this).popover('show')
		});
			$("#registerHere").validate({
				rules:{
					MaSanPham: "required",
					HinhAnh:"required",
					
				},
				messages:{
					MaSanPham: "Nhập vào sản phẩm",
					HinhAnh:"Nhập vào hình ảnh sản phẩm",
					
				},
				errorClass: "help-inline",
				errorElement: "span",
				highlight:function(element, errorClass, validClass) {
					$(element).parents('.control-group').addClass('error');
				},
				unhighlight: function(element, errorClass, validClass) {
					$(element).parents('.control-group').removeClass('error');
					$(element).parents('.control-group').addClass('success');
				}
			});
		});
</script>
<?php 
if (isset ($_REQUEST["MaHinh"]))
{
	include_once "../MyControl/connection.php";
	$MaHinh = $_REQUEST['MaHinh'];
	$sql = "SELECT * FROM hinhanh h, sanpham s WHERE h.MaSanPham=s.MaSanPham and MaHinh='" .$MaHinh."'";
	$result = mysql_query($sql);
	
	if($row = mysql_fetch_array($result))
	{
		$MaSanPham = $row ['MaSanPham'];
		$TenSanPham = $row['TenSanPham'];
		$TenHinh =$row['DuongDan'];
		
	}
}
?>
  <div class="container">
	  <div class="row">
	  		<div class="span8">
		<form class="form-horizontal" id="registerHere" method='post' action="../MyControl/capnhathinhanh.php" enctype="multipart/form-data">
	  <fieldset>
	    <legend>Sửa Hình Ảnh</legend>
        
       <div class="control-group">
              <label class="control-label" for="input01">Sản Phẩm</label>
              <div class="controls">
                <select name="MaSanPham" id="MaSanPham">
                    <option value="<?php if(isset($MaSanPham)) echo $MaSanPham;?>"><?php if(isset($MaSanPham)) echo $TenSanPham;?></option>
                    <?php
                        $sql="select * from sanpham";
                        $result=mysql_query($sql);
                        while($row=mysql_fetch_array($result))
						{
                            echo '<option value="'.$row["MaSanPham"].'">'.$row["TenSanPham"].'</option>';
                        }
                    ?>          
                </select>         
              </div>
        </div>
       	       
    <div class="control-group">
		<label class="control-label" for="HinhAnh">Hình Sản Phẩm</label>
	      <div class="controls">
	        <input type="file" class="input-xlarge" id="HinhAnh" name="HinhAnh" rel="popover" value="<?php if(isset($TenHinh)) echo $TenHinh;?>"/>
	       
	      </div>
	</div>
    <div class="control-group">
		<label class="control-label" for="input01"></label>
	      <div class="controls">
	       <button type="submit" class="btn btn-success" rel="tooltip" title="first tooltip" name="capnhathinh">Cập Nhật</button>
           &nbsp;
            &nbsp;
             &nbsp;
              &nbsp;
	        <button type="reset" class="btn btn-success" rel="tooltip" title="first tooltip">Nhập Lại</button>
	      </div>
			
	</div>
	</fieldset>
	</form>
   </div>
	
		</div>
        
        
          </div><!--/row-->
        </div><!--/span-->
      </div><!--/row-->
